*Analysis Do-File for creating Figures 7
	*Figures are separated in to 7a,b,c,d
*Runs event study regressions and produces graphs of effects over time

***File set-up
macro drop _all
mat drop _all
eststo clear
estimates clear
global path "[ENTER PATH HERE]"
global figs "$path\REStat Replication V2\Figures"
global log "$path\REStat Replication V2\Log Files"
set scheme lean2

clear
set more off

cap log close
log using "$log\figure_7.txt", replace text
use "$path\REStat Replication V2\Data\master_data_analysis_subset"

*Set folder for main figures
cd "$figs"


***Loops through crime types, producing the estimates that go into Figure 7
foreach var of varlist index_property mtr_veh_theft_tot burglary_tot theft_tot {
	
	***Analysis by qtr for extended event window
	di "------Reg `var' crime w/ no arrest missing------"
	reghdfe ln_actual_`var' ln_pop_s ///
		qtr_neg4_binned-qtr_neg2  qtr_0-qtr_6_binned ///
		if !inlist(., ln_`var', ln_actual_index_violent, ln_actual_index_property) ///
		, cl(group_ori) absorb(group_ori month_year)
			
	*Call plot code
	qui do "$path\REStat Replication\Code\coef_plot_quart"
			
	*Plot the normalized coefficents and SEs
	*Normalized to the negative first event (right before PK)
	*Plot with different y-axis depending on ori
	qui coefplot mat(coef_1000[,1]), vertical yline(0) se(2)  /// 
		yscale(range(-0.1 0.3))  ylabel(-0.1(0.1)0.3, glcolor(gs12)) ///
		msize(large) msymbol(O) mfcolor(black%100) mcolor(white%0) ///
		xtitle(Quarter Relative to Event) ytitle(Log Points) ///
		xline(3.5, lpattern(dash) lcolor(red) axis(1))
	
	if "`var'" == "index_property" {
		graph export "figure_7a.pdf", replace
	}
	else if "`var'" == "mtr_veh_theft_tot" {
		graph export "figure_7b.pdf", replace
	}
	else if "`var'" == "burglary_tot" {
		graph export "figure_7c.pdf", replace			
	}
	else if "`var'" == "theft_tot" {
		graph export "figure_7d.pdf", replace			
	}	
}


cap log close

